import {SlateElement} from '@wangeditor/editor'
import {h, VNode} from 'snabbdom'

type EmptyText = {
	text: ''
};
export type GapElement = {
	type: 'gapFilling'
	gapNum: number
	children: EmptyText[]
}

function renderGapElement(elem: SlateElement): VNode {
	const {gapNum = 1} = elem as GapElement
	return h(
		'span',
		{
			style: {
				color: '#f00',
				padding: '0 20px',
				margin: '5px',
				borderBottom: '1px solid #f00'
			}
		},
		[gapNum]
	)
}

export const renderGapConf = {
	type: 'gapFilling', // 新元素 type ，重要！！！即custom-type中定义的type
	renderElem: renderGapElement
}
